# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.su>

_realname=goxel
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=0.15.1
pkgrel=2
pkgdesc="3D program that lets you create voxel volumes (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://goxel.xyz/"
msys2_repository_url="https://github.com/guillaumechereau/goxel"
license=('spdx:GPL-3.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-glfw"
         "${MINGW_PACKAGE_PREFIX}-glew"
         "${MINGW_PACKAGE_PREFIX}-libpng"
         "${MINGW_PACKAGE_PREFIX}-libwinpthread"
         "${MINGW_PACKAGE_PREFIX}-libtre")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-scons"
             "${MINGW_PACKAGE_PREFIX}-pkgconf"
             "${MINGW_PACKAGE_PREFIX}-winpthreads")
source=("${msys2_repository_url}/archive/v$pkgver/$_realname-$pkgver.tar.gz"
        "001-goxel-0.11.0-msys-mingw.patch")
sha256sums=('01c9601ac9d8d38e29d3adff4b79a26c2b9fea4c2d2cb1d134471e499f8c4a84'
            '63af4960ecb3ac5eb43eeb89395512372b7614a72b193a225dc41893dee6a971')

prepare() {
  cd $_realname-$pkgver

  patch -Np1 -i "${srcdir}/001-goxel-0.11.0-msys-mingw.patch"
}

build() {
  msg "Build for ${MSYSTEM}"

  rm -rf build-${MSYSTEM} | true
  cp -r "${_realname}-${pkgver}" "build-${MSYSTEM}"
  cd "${srcdir}/build-${MSYSTEM}"

  "${MINGW_PREFIX}"/bin/scons mode=release werror=no
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  make DESTDIR="$pkgdir" PREFIX=${MINGW_PREFIX} install

  install -D -m644 COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/$_realname/LICENSE"
}
